<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserExtTable extends Migration
{
    /**
     * 创建用户扩展表
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_ext', function (Blueprint $table) {
            //表属性
            $table->engine = 'InnoDB';
            $table->charset = 'utf8';
            $table->collation = 'utf8_general_ci';
            //表字段
            $table->integer('user_id')->comment('用户id');
            $table->string('alias',20)->nullable()->comment('别名');
            $table->string('birth',20)->nullable()->comment('生日');

            $table->string('team',20)->nullable()->comment('团队');
            $table->string('wechat',20)->nullable()->comment('微信');
            $table->string('qq',20)->nullable()->comment('qq');
            $table->string('avatar',20)->nullable()->comment('头像');
            $table->string('home_page',20)->nullable()->comment('个人主页');

            $table->tinyInteger('sex')->default(1)->comment('性别,1:男,2:女');

            $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'))->comment('创建时间');
            $table->timestamp('updated_at')->nullable()->comment('更新时间');
            $table->timestamp('deleted_at')->nullable()->comment('删除时间');
            //创建索引
            $table->index('user_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_ext');
    }
}
